<template>
  <Dialog title="详情" v-model="dialogVisible" width="80%" center>
    <UserInfo :user="data">
      <template #header>
        <div class="card-header">
          <CardTitle title="个人信息" />
        </div>
      </template>
    </UserInfo>
    <UserSpousalCondition :user="data" class="mt4">
      <template #header>
        <div class="card-header">
          <CardTitle title="择偶条件" />
        </div>
      </template>
    </UserSpousalCondition>
  </Dialog>
</template>
<script setup lang="ts">
import * as UserApi from '@/api/member/user'
import UserInfo from './detail/UserInfo.vue'
import UserSpousalCondition from './detail/UserSpousalCondition.vue'

const dialogVisible = ref(false) // 弹窗的是否展示
const data = ref<UserApi.UserVO>({} as UserApi.UserVO)

/** 打开弹窗 */
const open = async (id?: number) => {
  dialogVisible.value = true
  // 修改时，设置数据
  if (id) {
    data.value = await UserApi.getUser(id)
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹
</script>
<style scoped lang="scss">
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
